package com.example.yyg.springframework.beans;

import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: 冰岩
 * @Date: 2023/05/28
 * @Description:
 */
@Data
public class PropertyValues {

    List<PropertyValue> propertyValueList = new ArrayList<>();

    public void addProperty(PropertyValue propertyValue) {
        propertyValueList.add(propertyValue);
    }

    public Object getProperty(String propertyName) {
        for (PropertyValue propertyValue:propertyValueList) {
            if (propertyValue.getName().equals(propertyName)) {
                return propertyValue.getValue();
            }
        }
        return null;
    }

    public boolean isEmpty() {
        return CollectionUtils.isEmpty(propertyValueList);
    }

}
